<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>parseFloat和parseInt</title>
  </head>

  <body>

  </body>
  <script>
    /* 
      使用专门的方式对付字符串:如果对非String使用parseInt()或parseFloat()，它会先将其转换为String然后在操作
        1.parseInt(string, radix)：
          1.1 可以将一个字符串中的有效的整数内容去出来，然后转换为Number
          1.2 可以进行进制转换 
        2.parseFloat(string)
    */
    console.log(parseInt('123')); //123
    console.log(parseInt('123,1233')); //123
    console.log(parseInt('123a')); //123
    console.log(parseInt('a123')); //NaN
    console.log(parseInt(null)); //NaN
    console.log(parseInt(undefined)); //NaN
    console.log(parseInt(true)); //NaN

    console.log('------------------------')
    console.log(parseInt("111", 2)); //7，转换为二进制7
    console.log(parseInt('100', 8)); //64,转换为八进制64
    console.log(parseInt('111', 16)); //16^2+16^1*1+16^0*1=273,转换为16进制273


    console.log('------------------------')
    console.log(parseFloat('123,1233')); //123
    console.log(parseFloat(null)); //NaN
  </script>

</html>